#include "setVolumeMessage.h"
#include "jsonUtils.h"

SetVolumeMessage::SetVolumeMessage(MtpProtocol* packet) : MtpMessage(packet),volume(0)
{
}

SetVolumeMessage::SetVolumeMessage(const int64_t& movieId, const int& scene, const int& volume)
	: MtpMessage(new MtpProtocol(L"setVolume")),param(movieId,scene),volume(volume)
{
}

void SetVolumeMessage::decodeBody()
{
	MtpMessage::decodeBody();
	JsonDoc& doc = param.jsonDeserialize(jsonContent);
	JsonUtils::loadInt(doc, L"volume", volume);
}

void SetVolumeMessage::encodeBody()
{
	JsonDoc& doc = param.jsonSerialize();
	doc.AddMember(L"volume", volume, doc.GetAllocator());
	jsonContent = JsonUtils::jsonStr(doc);
	MtpMessage::encodeBody();
}

const int64_t& SetVolumeMessage::getMovieId()
{
	return param.getMovieId();
}

const int& SetVolumeMessage::getVolume()
{
	return volume;
}
